const responseHandler = async (ctx, next) => {
    const setResponse = (code, msg, data) => {
      ctx.body = { code, msg, data };
    };
  
    ctx.success = (msg, data) => setResponse(200, msg, data);
    ctx.fail = (msg, data) => setResponse(500, msg, data);
    ctx.tokenExpires = (msg, data) => setResponse(403, msg, data);
    ctx.noUser = (msg, data) => setResponse(401, msg, data);
  
    await next();
  };
  
  module.exports = responseHandler;
  